package com.ygqh.baby.utils;

import java.util.Date;

public class ExceptionUtil {
	
	public static String getExceptionMsg(Exception e) {
		StringBuilder sb = new StringBuilder();
		sb.append(DateConvertUtils.formatDateTime(new Date()) + ":" + e.getMessage()).append("</br>");
		StackTraceElement[] st = e.getStackTrace();
		for (StackTraceElement stackTraceElement : st) {
			String exclass = stackTraceElement.getClassName();
			String method = stackTraceElement.getMethodName();
			if (exclass.contains("com.ygqh.baby")) {
				sb.append("[类:" + exclass + "]调用" + method + "时在第" + stackTraceElement.getLineNumber()
						+ "行代码处发生异常!异常类型:" + e.getClass().getName() + "</br>");
			}
		}
		return sb.toString();
	}

}
